# 斐波那契数列
def fib(n):
    if n < 2:
        return n
    else:
        return fib(n - 2) + fib(n - 1)
# 快排
def quick(qlist):
    if len(qlist) < 1:
        return qlist
    else:
        qb = qlist[0]
        qa = quick([m for m in qlist[1:] if m < qb])
        qc = quick([l for l in qlist[1:] if l >= qb])
        return qa + [qb] + qc

print(quick([343, 23, 14, 523, 2532]))

# 随机排序

# 99乘法表
def n_n():
    for i in range(1, 10):
        for j in range(1, i+1):
            print(f'{j} * {i} = {j*i}  ', end=' ')
        print('\t')
n_n()

# 统计字符串中出现次数最多的字符和次数
def tjzfc(s):
    d1 = {}
    for i in s:
        if i not in d1:
            d1[i] = 1
        else:
            d1[i] += 1
    # d1Max = max(d1.values())
    for k, v in d1.items():
        if v == max(d1.values()):
            print(k, v)
tjzfc("asasdafavafadsad")

# Switch语句3,可以写道一个函数里，然后return返回出来结果，给其他逻辑当一个参数
s1= {"1":"a", "2":"b", "3":"c", }
# i = input("请输入123其中的一个")
print(s1["2"])



# map()映射方法
def add(i):
    i += 1
    return i

print(list(map(add, [23, 34, 45, 63])))




# filter()筛选
def fadd(i):
    if not i.startswith("z"):
        return True

# 获取list索引位置
list1 = [2, 3, 12, 43, 234]
print(list1.index(234))


# 判断字符串中大写的几个，小写的几个
s2 = "ACASCASCsacascaACACcCACSAC"
d1 = {}
for i in s2:
    if i not in d1:
        d1[i] = 1
    else:
        d1[i] += 1

for k, v in d1.items():
    if v == max(d1.values()):
       print(k, v)